import redis


host = "192.168.10.5"
port = 6379
pool = redis.ConnectionPool(
    host=host, port=port, db=2, decode_responses=True, password="steward1!"
)
rc = redis.StrictRedis(connection_pool=pool)
def get_main_instruments(redis_client=rc):
    """获取主力合约"""

    data = redis_client.hgetall("main_future_dict")
    mii=None
    for emi in data.values():
        if mii:
            mii.extend(emi.split(","))
        else:
            mii=emi.split(",")
    return mii

def get_market_instruments(redis_client=rc):
    """获取各交易所所有合约"""

    data = redis_client.hgetall("exchange_future_dict")
    mii=dict()
    for k,v in data.items():
        mii[k]=v.split(",")

    return mii
if __name__ == "__main__":
    print(get_market_instruments())

